<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <title>统一收银台-测试页</title>
  <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0" />
  <style>
    body,
    html {
      height: 100%;
      -webkit-tap-highlight-color: transparent;
    }

    body {
      font-family: -apple-system-font, Helvetica Neue, Helvetica, sans-serif;
    }

    ul {
      list-style: none;
    }

    .page,
    body {
      background-color: #ededed;
    }

    #lbl_login_status,
    #btn-purchase,
    #btn-myorder,
    #btn-myserver {
      margin-bottom: 20px;
    }

    .weui-btn {
      width: 220px !important;
    }

    .weui-form__ft {
      margin: 15px !important;
    }
  </style>
  <link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/2.0.1/weui.min.css" />
</head>

<body ontouchstart="">
  <div class="container" id="container">
    <div class="page input js_show">
      <div class="page__bd">
        <div class="weui-cells__title"></div>
        <div class="weui-cells weui-cells_form">
          <div class="weui-btn-area">
            <div id="lbl_login_status" style="text-align: center">
              查询中...
            </div>
            <a id="btn-myorder" class="weui-btn weui-btn_primary" href="javascript:" style="display:none">
              我的订单
            </a>
            <a id="btn-myserver" class="weui-btn weui-btn_primary" href="javascript:" style="display:none">
              我的增值服务
            </a>
            <a id="btn-purchase" class="weui-btn weui-btn_primary" href="javascript:">
              购买该权益
            </a>
          </div>
        </div>
      </div>
    </div>
    <div class="page">
      <div class="weui-form">
        <div class="weui-form__bd">
          <div class="weui-form__control-area">
            <div class="weui-cells__group weui-cells__group_form">
              <div class="weui-cells__title">观点包产品代码</div>
              <div class="weui-cells weui-cells_form">
                <div class="weui-cell weui-cell_active">
                  <div class="weui-cell__bd">
                    <textarea id="txt-winnerPointer" class="weui-textarea" placeholder="请输入观点包产品代码" rows="2"></textarea>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="weui-form__ft">
          <div class="weui-form__opr-area">
            <a role="button" class="weui-btn weui-btn_primary" href="javascript:" id="btn-winnerPoint">跳转至观点包详情页</a>
          </div>
        </div>
      </div>
    </div>
    <div class="page">
      <div class="weui-form">
        <div class="weui-form__bd">
          <div class="weui-form__control-area">
            <div class="weui-cells__group weui-cells__group_form">
              <div class="weui-cells__title">投顾ID</div>
              <div class="weui-cells weui-cells_form">
                <div class="weui-cell weui-cell_active">
                  <div class="weui-cell__bd">
                    <textarea id="txt-adviserHome" class="weui-textarea" placeholder="请输入投顾ID" rows="2"></textarea>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="weui-form__ft">
          <div class="weui-form__opr-area">
            <a role="button" class="weui-btn weui-btn_primary" href="javascript:" id="btn-adviserHome">跳转至投顾号首页</a>
          </div>
        </div>
      </div>
    </div>
    <div class="page">
      <div class="weui-form">
        <div class="weui-form__bd">
          <div class="weui-form__control-area">
            <div class="weui-cells__group weui-cells__group_form">
              <div class="weui-cells__title">股票代码</div>
              <div class="weui-cells weui-cells_form">
                <div class="weui-cell weui-cell_active">
                  <div class="weui-cell__bd">
                    <textarea id="txt-stockDetail-1" class="weui-textarea" placeholder="请输入股票代码"
                      rows="1">000948</textarea>
                  </div>
                </div>
              </div>
            </div>
            <div class="weui-cells__group weui-cells__group_form">
              <div class="weui-cells__title">市场</div>
              <div class="weui-cells weui-cells_form">
                <div class="weui-cell weui-cell_active">
                  <div class="weui-cell__bd">
                    <textarea id="txt-stockDetail-2" class="weui-textarea" placeholder="请输入市场" rows="1">SZ</textarea>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="weui-form__ft">
          <div class="weui-form__opr-area">
            <a role="button" class="weui-btn weui-btn_primary" href="javascript:" id="btn-stockDetail">跳转股票行情</a>
          </div>
        </div>
      </div>
    </div>
    <div class="page">
      <div class="weui-form">
        <div class="weui-form__bd">
          <div class="weui-form__control-area">
            <div class="weui-cells__group weui-cells__group_form">
              <div class="weui-cells__title">直播间ID</div>
              <div class="weui-cells weui-cells_form">
                <div class="weui-cell weui-cell_active">
                  <div class="weui-cell__bd">
                    <textarea id="txt-channel-1" class="weui-textarea" placeholder="请输入直播间ID"
                      rows="1">6405410</textarea>
                  </div>
                </div>
              </div>
            </div>
            <div class="weui-cells__group weui-cells__group_form">
              <div class="weui-cells__title">mediaID</div>
              <div class="weui-cells weui-cells_form">
                <div class="weui-cell weui-cell_active">
                  <div class="weui-cell__bd">
                    <textarea id="txt-media-1" class="weui-textarea" placeholder="请输mediaID" rows="1">522</textarea>
                  </div>
                </div>
              </div>
            </div>
            <div class="weui-cells__group weui-cells__group_form">
              <div class="weui-cells__title">类型</div>
              <div class="weui-cells weui-cells_form">
                <div class="weui-cell weui-cell_active">
                  <div class="weui-cell__bd">
                    <textarea id="txt-action-2" class="weui-textarea" placeholder="请输入操作类型"
                      rows="1">subscribe</textarea>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="weui-form__ft">
          <div class="weui-form__opr-area">
            <a role="button" class="weui-btn weui-btn_primary" href="javascript:" id="btn-subscribe">操作</a>
          </div>
        </div>
      </div>
    </div>
    <div class="page">
      <div class="weui-form">
        <div class="weui-form__bd">
          <div class="weui-form__control-area">
            <div class="weui-cells__group weui-cells__group_form">
              <div class="weui-cells__title">唤起app</div>
              <div class="weui-cells weui-cells_form">
                <div class="weui-cell weui-cell_active">
                  <div class="weui-cell__bd">
                    <textarea id="txt-callapplink-1" class="weui-textarea" placeholder="请输入地址"
                      rows="1">https://www.baidu.com</textarea>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="weui-form__ft">
          <div class="weui-form__opr-area">
            <a role="button" class="weui-btn weui-btn_primary" href="javascript:" id="btn-callapp">唤起</a>
          </div>
        </div>
      </div>
    </div>
    <div class="page">
      <div class="weui-form">
        <div class="weui-form__bd">
          <div class="weui-form__control-area">
            <div class="weui-cells__group weui-cells__group_form">
              <div class="weui-cells__title">唤起保利威直播间</div>
              <div class="weui-cells weui-cells_form">
                <div class="weui-cell weui-cell_active">
                  <div class="weui-cell__bd">
                    <textarea id="txt-channelID-1" class="weui-textarea" placeholder="channelID"
                      rows="1">6405410</textarea>
                  </div>
                </div>
              </div>
              <div class="weui-cells weui-cells_form">
                <div class="weui-cell weui-cell_active">
                  <div class="weui-cell__bd">
                    <textarea id="txt-mediaID-1" class="weui-textarea" placeholder="mediaID" rows="1">522</textarea>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="weui-form__ft">
          <div class="weui-form__opr-area">
            <a role="button" class="weui-btn weui-btn_primary" href="javascript:" id="btn-callapp-polyv">唤起</a>
          </div>
        </div>
      </div>
    </div>
    <div class="weui-footer">
      <p class="weui-footer__text">Copyright © 2019-2025 orientsec.ued</p>
    </div>
  </div>
  <script src="https://h5itest1.dfzq.com.cn/open/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://h5itest1.dfzq.com.cn/open/vConsole/3.3.4/vconsole.min.js"></script>
  <script>
    var vConsole = new VConsole();
  </script>
  <script src="https://res.wx.qq.com/t/wx_fed/cdn_libs/res/weui/1.2.3/weui.min.js"></script>
  <script src="https://h5itest1.dfzq.com.cn/open/dfzq-jsbridge-2.1.1.js"></script>
  <!-- <script src="https://h5itest1.dfzq.com.cn/open/dfzq-jsapis-test-1.1.1.js"></script> -->

  <script src="./dfzq-jsapis-test-1.1.2.js?a=20"></script>
  <script>
    // 检查登录状态，如果是页面初始化要做检查，建议放在fastman.onViewWillAppear中
    var checkLoginStatus = function () {
      // 检查是否登录，使用这个特性可以实现一些游客性质的预览功能
      var isLogin = dfzqJsApis.isLogin().then(_isLogin => {
        console.log("checkLoginStatus:" + _isLogin);
        if (_isLogin === "0") {
          $("#btn-myorder").hide();
          $("#btn-myserver").hide();
          $("#lbl_login_status").html("您还未登录");
        } else {
          $("#btn-myorder").show();
          $("#btn-myserver").show();
          $("#lbl_login_status").html("您已登录 ^_^");
        }
      });
    }

    fastman.ready(function () {
      fastman.onViewWillAppear(function () {
        console.log("onViewWillAppear checkLoginStatus trigger.")
        checkLoginStatus();
      });

      checkLoginStatus();

      // 所有的桥接接口都必须在ready接口执行成功后才可被调用，如果需要在页面加载时就调用相关桥接接口，则需把相关接口放在ready函数中调用来确保正确执行。
      $("#btn-purchase").on("click", function (options) {
        var productCode = "Level2plus";
        dfzqJsApis
          .queryPurchaseEquities({
            productCode: productCode,
          })
          .then((resp) => {
            console.log("[ok]:" + JSON.stringify(resp));
            // 该权益未购买或已过期
            if (!resp.hasPrivilege) {
              weui.dialog({
                title: "提示",
                content: "该权益未购买获已过期，请先购买",
                buttons: [{
                  label: "取消",
                  type: "default"
                }, {
                  label: '确定',
                  type: 'primary',
                  onClick: function () {
                    // 跳转至“统一收银台”进行支付
                    dfzqJsApis.unifyCashierDesk({
                      // 请与你的运营人员确认该权益是商品还是产品
                      productCode: productCode
                    });
                  }
                }]
              });
            }
            // 该权益已购买，可正常使用
            else {
              weui.alert("该权益已购买，可正常使用!");
            }
          })
          .catch(err => {
            // 用户在原生登录页取消了登录
            if (err.code == "-1") {
              alert(err.info);
            } else {
              alert("[error]:" + JSON.stringify(err));
            }
          });
      });

    });

    // 我的订单跳转
    $("#btn-myorder").on("click", function (options) {
      dfzqJsApis.unifyMyOrders();
    });

    // 我的增值服务跳转
    $("#btn-myserver").on("click", function (options) {
      weui.alert("跳转至我的增值服务单页");
    });

    // 观点包详情页跳转
    $("#btn-winnerPoint").on("click", function (options) {
      var productCode = $("#txt-winnerPointer").val();
      if (productCode) {
        dfzqJsApis.unifyWinnerPoint({
          productCode: productCode
        });
      } else {
        weui.alert("请输入观点包产品代码");
      }
    });

    // 投顾号首页跳转
    $("#btn-adviserHome").on("click", function (options) {
      var winnerSID = $("#txt-adviserHome").val();
      if (winnerSID) {
        dfzqJsApis.unifyAdviserHome({
          winnerSID: winnerSID
        });
      } else {
        weui.alert("请输入投顾ID");
      }
    });
    // 投顾号首页跳转
    $("#btn-stockDetail").on("click", function (options) {
      var code = $("#txt-stockDetail-1").val();
      var market = $("#txt-stockDetail-2").val();
      if (code && market) {
        dfzqJsApis.unifyStockDetail({
          code,
          market
        });
      } else {
        weui.alert("请输入投顾ID");
      }
    });
    // 投顾号首页跳转
    $("#btn-subscribe").on("click", function (options) {
      var channel = $("#txt-channel-1").val();
      var media = $("#txt-media-1").val();
      var action = $("#txt-action-2").val();
      console.log(channel, media, action);
      if (channel && action && media) {
        dfzqJsApis.unifySubscribeLive({
          requestNo: new Date().getTime().toString(),
          channelID: channel,
          mediaID: media,
          action: action,
        }).then(function (res) {
          console.log(JSON.stringify(res.data.data), "unifySubscribeLive: res ")
        });
      } else {
        weui.alert("请输入参数");
      }
    });
    // 唤起app按钮
    $("#btn-callapp").on("click", function (options) {
      var link = $("#txt-callapplink-1").val();
      // link = "https://zqtgtest.dfzq.com.cn/#/stockPoolDetail/eyJwb29sSWQiOilyMyIsInBkSWQiOilzOClsInNlbGZKdW1wlip0cnVlfQ==";
      // link = "https://cfyjh5-v3.dfzq.com.cn/short-video-detail-h5/index.html?a=2&b=3#/pages/shortVideoDetail/index?mediaID=3bbd768871fd46d6a007b755297408c9";
      // link = "https://h5itest1.dfzq.com.cn/live-video-square-h5/index.html#/pages/liveVideoSquare/index";
      // link = "https://cfyjh5-v3.dfzq.com.cn/winner-adviser-homepage-h5/index.html?winnerSID=22";
      if (!link)
        link = window.location.href;
      console.log("callapp:" + link);
      dfzqJsApis.unifyCallAppUrl({
        url: link
      })
      // dfzqJsApis.unifyQuerySubscribeList?.({
      //   mediaList:['580','583','585']
      // }).then(res=>{
      //   console.log(JSON.stringify(res.data.data.mediaSubscribeStatus));
      // })
    });
    // 唤起app按钮
    $("#btn-callapp-polyv").on("click", function (options) {
      var channelID = $("#txt-channelID-1").val();
      var mediaID = $("#txt-mediaID-1").val();

      dfzqJsApis.unifyCallappPolyv({
        channelID: channelID,
        mediaID: mediaID
      })

    });
  </script>
</body>

</html>